package {
    import org.flixel.*;

    public class StateGameOver extends FlxState	{
        override public function create():void {
            var _inst:FlxText = new FlxText(0, 250, FlxG.width,
                    "Game Over");
            _inst.setFormat(null, 18, 0xFFFFFFFF, "center", 0xFF999999);
            add(_inst);

            var _keys:FlxText = new FlxText(0, 280, FlxG.width, "Press X, C To Try Again");
            _keys.setFormat(null, 18, 0xFFD9D0CF, "center", 0xFF999392);
            add(_keys);
			
			var _record:FlxText = new FlxText(0, 30, FlxG.width, "SCORE: " + FlxG.score);
			_record.setFormat(null, 30, 0xFFFFFFFF, "center", 0XFF9999392);
			add(_record);
			
			if (FlxG.score > Main._high_score)
				Main._high_score = FlxG.score;
			
			var _max_record:FlxText = new FlxText(0, 60, FlxG.width, "HIGH SCORE: " + Main._high_score);
			_max_record.setFormat(null, 18, 0xFFFFFFFF, "center", 0XFF9999392);
			add(_max_record);			

            FlxG.panel.setup("", 0, "Last Space Defenfer", "", "");
            FlxG.mouse.show();
            FlxG.panel.show();

            super.create();
        }

        override public function update():void {
            if(FlxG.keys.justPressed("C") || FlxG.keys.justPressed("X")) {
                FlxG.fade.start(0xff000000, 0.5, function():void {
                        FlxG.state = new StatePlay();});
            }

            super.update();
        }
    }
}
